/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.LoggedData;


/**
 *
 * @author DOStudent1
 */
public class LoggedLogableNumber implements LoggedLogableObject{

    private String loggedString;
    private boolean isSet=false;
    
    public LoggedLogableObject fromLogableObject(LogableObject myNumber) {
        LoggedLogableNumber loggedMyNumber=new LoggedLogableNumber();
        if (myNumber.isEmpty()) {
            loggedMyNumber.loggedString="";
            loggedMyNumber.isSet=true;
        } else { 
            long number=((LogableNumber)myNumber).getNumber();
            loggedMyNumber.loggedString=Long.toString(number);
            loggedMyNumber.isSet=true;
        }
        return(loggedMyNumber);
    }
    
    public LogableObject toLogableObject() {
        if (!isSet) {
            throw new RuntimeException("Not initialized");
        }
        long number=Long.parseLong(loggedString);
        return(new LogableNumber().fromNumber(number));
    }

    public String toLoggedValue() {
        if (!isSet) {
            throw new RuntimeException("Not initialized");
        }
        return(loggedString);
    }

    public LoggedLogableObject fromLoggedValue(String loggedValue) {
        LoggedLogableNumber loggedMyObject=new LoggedLogableNumber();
        loggedMyObject.loggedString=loggedValue;
        loggedMyObject.isSet=true;
        return(loggedMyObject);
    }
}
